﻿using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Runtime.Remoting.Messaging;
namespace Kwan.Core
{
    public class File
    {
        public string Name
        {
            get;
            set;
        }
        public long Size
        {
            get;
            set;
        }
        public string FileType
        {
            get;
            set;
        }
        public byte[] Data
        {
            get;
            set;
        }

       
        public void Save(string filename)
        {
            using (FileStream fs = System.IO.File.Open(filename, FileMode.Create, FileAccess.Write))
            {

                fs.Write(Data, 0, Data.Length);
                fs.Flush();
                fs.Close();
            }

        }
        public void AsynSave(string filename)
        {
            Action<string> action = Save;
            action.BeginInvoke(filename, iar =>
            {
                Action<string> end = (Action<string>)((AsyncResult)iar).AsyncDelegate;
                end.EndInvoke(iar);
            }, null);
        }
    }
}
